/*
 * Copyright (c) 2016-2021, Hangzhou Qulian Technology Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "CuTest.h"
#include "stdio.h"
#include "log.h"
#include <time.h>

extern CuSuite* x509_test_suite(void);
extern CuSuite* account_test_suite(void);
extern CuSuite* keccak256_test_suite(void);
extern CuSuite* ecc_test_suite(void);

void RunAllTests(void)
{
    CuString *output = CuStringNew();
    CuSuite* suite = CuSuiteNew();

    CuSuiteAddSuite(suite, x509_test_suite());
    CuSuiteAddSuite(suite, account_test_suite());
    CuSuiteAddSuite(suite, keccak256_test_suite());
    CuSuiteAddSuite(suite, ecc_test_suite());

    CuSuiteRun(suite);
    CuSuiteSummary(suite, output);
    CuSuiteDetails(suite, output);
    printf("%s\n", output->buffer);
    CuStringDelete(output);
    CuSuiteDelete(suite);
}

void print_log_func(char *content){
    printf("%s",content);
}
void print_log_time(char * timeBuf, int size){
    time_t t = time(NULL);
    struct tm* tp = localtime(&t);
    timeBuf[strftime(timeBuf, size, "%H:%M:%S", tp)] = '\0';
}
int main()
{
    SetPrintLogCallback(print_log_func);
    SetGetTimeCallback(print_log_time);
    LogSetQuiet(LOG_QUIET_FALSE);
    LogSetLevel(LOG_DEBUG);
    RunAllTests();
    return 0;
}
